#include "vec234.h"
#include <assert.h>
#include <math.h>

void 
normalize(vec3 *self)
{
	float mag = 0;
	assert(self);

	mag = sqrt(self->x * self->x + self->y * self->y + self->z * self->z);  
	self->x /= mag;
	self->y /= mag;
	self->z /= mag;
}

void 
cross_product(vec3 *a, vec3 *b, vec3 *res)
{
	assert(a);
	assert(b);
	assert(res);

	res->x = a->y * b->z - b->y * a->z;
	res->y = a->z * b->x - b->z * a->x;
	res->z = a->x * b->y - b->x * a->y;
}